let cfg_target = try!(config.get_string("build.target")).map(|s| s.val);
let target = target.or(cfg_target);
let mut base = ops::BuildConfig {
- jobs: jobs,
+ host_triple: config.rustc_info().host.clone(),
requested_target: target.clone(),
+ jobs: jobs,
..Default::default()
};
- base.host = try!(scrape_target_config(config, &config.rustc_info().host));
+ base.host = try!(scrape_target_config(config, &base.host_triple));
base.target = match target.as_ref() {
Some(triple) => try!(scrape_target_config(config, &triple)),
None => base.host.clone(),
host: Layout,
target: Option<Layout>,
- target_triple: String,
target_info: TargetInfo,
host_info: TargetInfo,
profiles: &'a Profiles,
None => None,
};
- let target = build_config.requested_target.clone();
- let target = target.as_ref().map(|s| &s[..]);
- let target_triple = target.unwrap_or_else(|| {
- &config.rustc_info().host[..]
- }).to_string();
let engine = build_config.exec_engine.as_ref().cloned().unwrap_or({
Arc::new(Box::new(ProcessEngine))
});
Ok(Context {
- target_triple: target_triple,
host: host_layout,
target: target_layout,
resolve: resolve,
try!(self.visit_crate_type(unit, &mut crate_types));
}
try!(self.probe_target_info_kind(&crate_types, Kind::Target));
- if self.build_config.requested_target.is_none() {
+ if self.requested_target().is_none() {
self.host_info = self.target_info.clone();
} else {
try!(self.probe_target_info_kind(&crate_types, Kind::Host));
process.arg("--crate-type").arg(crate_type);
}
if kind == Kind::Target {
- process.arg("--target").arg(&self.target_triple);
+ process.arg("--target").arg(&self.target_triple());
}
let mut with_cfg = process.clone();
/// Return the host triple for this context
pub fn host_triple(&self) -> &str {
- &self.config.rustc_info().host[..]
+ &self.build_config.host_triple
}
/// Return the target triple which this context is targeting.
pub fn target_triple(&self) -> &str {
- &self.target_triple
+ self.requested_target().unwrap_or(self.host_triple())
}
/// Requested (not actual) target for the build
if unsupported.len() > 0 {
bail!("cannot produce {} for `{}` as the target `{}` \
does not support these crate types",
- unsupported.join(", "), unit.pkg, self.target_triple)
+ unsupported.join(", "), unit.pkg, self.target_triple())
}
bail!("cannot compile `{}` as the target `{}` does not \
support any of the output crate types",
- unit.pkg, self.target_triple);
+ unit.pkg, self.target_triple());
}
Ok(ret)
}
#[derive(Default, Clone)]
pub struct BuildConfig {
+ pub host_triple: String,
pub host: TargetConfig,
+ pub requested_target: Option<String>,
pub target: TargetConfig,
pub jobs: u32,
- pub requested_target: Option<String>,
pub exec_engine: Option<Arc<Box<ExecEngine>>>,
pub release: bool,
pub test: bool,